<template>
  <div class="container">
    <div class="app-container">
      <el-button type="primary" style="margin: 20px 0 0 20px; border-radius: 10px;">增加停车计费规则</el-button>
      <el-table :data="list" style="width: 100%; margin-top: 20px;">
        <el-table-column align="center" type="index" label="序号" width="50" />
        <el-table-column align="center" prop="ruleNumber" label="计费规则编号" width="180" />
        <el-table-column align="center" prop="ruleName" label="计费规则名称" />
        <el-table-column align="center" prop="freeDuration" label="免费时长(分钟)" width="150" />
        <el-table-column align="center" prop="chargeCeiling" label="收费上限(元)" width="150">
          <!-- <template #default="{row}">
            {{ row.chargeCeiling ? row.chargeCeiling : '---' }}
          </template> -->
        </el-table-column>
        <el-table-column align="center" prop="chargeType" label="计费方式">
          <template #default="{row}">
            {{ row.chargeType == "duration" ? '时长收费' : (row.chargeType == "turn" ? '按次收费' : '分段收费') }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="ruleNameView" label="计费规则" />
        <el-table-column align="center" label="操作" width="180">
          <template>
            <el-button size="mini" type="text">编辑</el-button>
            <el-button size="mini" type="text">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        layout="total, sizes, prev, pager,jumper, next"
        :total="pageParams.total"
        :page-size="pageParams.pageSize"
        :current-page="pageParams.page"
        :page-sizes="[10, 20, 50, 100]"
      />
    </div>
  </div>
</template>
<script>
import { getBillingRuleListAPI } from '@/api'

export default {
  name: 'BillingRules',
  data() {
    return {
      list: [],
      pageParams: {
        page: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  created() {
    this.getBillingRuleList()
  },
  methods: {
    async getBillingRuleList() {
      const { rows, total } = await getBillingRuleListAPI(this.pageParams)
      this.list = rows
      this.pageParams.total = total
    }
  }
}
</script>
